module.exports = function (url, callback = () => {}, error = () => {}) {
  return new Promise((reslove, reject) => {
    var script = document.createElement("script");
    script.src = url;
    document.body.appendChild(script);
    if (script.addEventListener) {
      script.addEventListener(
        "load",
        function () {
          callback();
          reslove();
        },
        false
      );
      script.addEventListener(
        "error",
        function (e) {
          error(e);
          reject(e);
        },
        false
      );
    } else if (script.attachEvent) {
      script.attachEvent("onreadystatechange", function () {
        var target = window.event.srcElement;
        if (target.readyState == "loaded") {
          callback();
          reslove();
        }
      });
    }
  });
};
